#include "showinfo.h"
#include "ui_showinfo.h"
#include <QFile>
#include <QTextCodec>

Showinfo::Showinfo(QDialog *parent) :
    QDialog(parent),
    ui(new Ui::Showinfo)
{
    ui->setupUi(this);
    showinfo();
    ui->textEdit->setFocusPolicy(Qt::NoFocus);
}

Showinfo::~Showinfo()
{
    delete ui;
}

void Showinfo::showinfo()
{
    QString displayString;
    QFile file("./ShowInfo/showinfo.txt");
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
         ui->textEdit->setText("Open file[./ShowInfo/showinfo.txt] failed!");
         return;
    }

    QTextCodec *codec = QTextCodec::codecForName("GBK");
    QFont ft;
    ft.setPointSize(12);


    while(!file.atEnd())
    {
        QByteArray line = file.readLine();
        QString str = codec->toUnicode(line);
        displayString.append(str.toUtf8());

    }
   ui->textEdit->clear();
   ui->textEdit->setFont(ft);
   ui->textEdit->setPlainText(displayString);
}
